package com.dc.controller;

import com.dc.common.ResponseResultVO;
import com.dc.entity.SysJobLog;
import com.dc.service.ISysJobLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 调度日志操作处理
 *
 * @author ruoyi
 */
@RestController
@RequestMapping("/job/log")
public class SysJobLogController {
    @Autowired
    private ISysJobLogService jobLogService;

    /**
     * 查询定时任务调度日志列表
     */
    @GetMapping("/list")
    public ResponseResultVO list(SysJobLog sysJobLog) {
        List<SysJobLog> list = jobLogService.selectJobLogList(sysJobLog);
        return ResponseResultVO.successResult(list);
    }

    /**
     * 根据调度编号获取详细信息
     */
    @GetMapping(value = "/{configId}")
    public ResponseResultVO getInfo(@PathVariable Long jobLogId) {
        return ResponseResultVO.successResult(jobLogService.selectJobLogById(jobLogId));
    }

    /**
     * 删除定时任务调度日志
     */
    @DeleteMapping("/{jobLogIds}")
    public ResponseResultVO remove(@PathVariable Long[] jobLogIds) {
        return ResponseResultVO.deleteResult(jobLogService.deleteJobLogByIds(jobLogIds));
    }

    /**
     * 清空定时任务调度日志
     */
    @DeleteMapping("/clean")
    public ResponseResultVO clean() {
        jobLogService.cleanJobLog();
        return ResponseResultVO.successResult("成功");
    }
}
